﻿using System;
using System.Collections.Generic;
using System.Text;
//new
using System.IO;
using System.Threading;
using JRCore.tools;
using DataRecv.models.device;
using DataRecv.tools;
using System.Collections;
using DataRecv.enums;

namespace DataRecv.models.road
{
    /// <summary>
    /// 路口类
    /// </summary>
    public class Road
    {
        /// <summary>
        /// 路口参数
        /// </summary>
        public RoadParam param;

        /// <summary>
        /// 卡口存储路径集合，用于空间回收
        /// </summary>
        public static List<string> KKDistinctPathList = new List<string>();
        /// <summary>
        /// 电警存储路径集合，用于空间回收
        /// </summary>
        public static List<string> DJDistinctPathList = new List<string>();

        /// <summary>
        /// 空构造
        /// </summary>
        public Road()
        {
            param = null;
        }

        /// <summary>
        /// 加载所有路口
        /// </summary>
        /// <returns></returns>
        public static Hashtable GetModels()
        {
            Hashtable ans = new Hashtable();
            try
            {
                List<RoadParam> roadparams = RoadParam.GetModels();
                if ((roadparams != null) && (roadparams.Count > 0))
                {
                    foreach (RoadParam rp in roadparams)
                    {
                        
                        Road road = new Road();
                        road.param = rp;
                        ans.Add(rp.roadid, road);

                        if (KKDistinctPathList.Contains(rp.kkpath) == false) KKDistinctPathList.Add(rp.kkpath);
                        if (DJDistinctPathList.Contains(rp.djpath) == false) DJDistinctPathList.Add(rp.djpath);
                    }
                }
            }
            catch 
            {
                ans = null;
            }
            return ans;
        }

    }
}
